var express = require("express");
var router = express.Router();
const { find } = require("./database.js");
/* GET home page. */
router.post("/", async function (req, res, next) {
  // 去数据库查找是否有相同的
  // res.send({result:true});
  let userList = await find("_id>=0");
  let user_online = await find("online===true");
  if (user_online.length !== 0) {
    res.send({ result: true, user: user_online[0].accountName, userList });
  } else {
    res.send({ result: false });
  }
});

module.exports = router;
